#
# @lc app=leetcode.cn id=209 lang=python3
#
# [209] 长度最小的子数组
#

# @lc code=start
class Solution:
    def minSubArrayLen(self, target: int, nums: List[int]) -> int:
        left = 0
        right = 0
        sums = 0
        min_len = float('inf')
        num_len = len(nums)
        while right < num_len :
            sums += nums[right]
            while sums >= target :
                min_len = min(min_len,right - left + 1)
                sums -= nums[left]
                left += 1
            right += 1
        return min_len if min_len != float('inf') else 0

# @lc code=end

